package com.shundr.shipper.base;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.shundr.shipper.R;

public class BaseFullScreenDialog extends Dialog implements android.view.View.OnClickListener{
	
	protected Button btnBack;
	protected ImageView ivIcon;
	protected TextView tvTitle;
	
	private RelativeLayout mLayoutBack;
	protected LinearLayout mLayoutMain;
	
	protected RelativeLayout mLayoutNoContent;
	protected TextView tvNoContent;
	protected Button btnRight;
	
	protected Context mContext;
	protected View mView;

	public BaseFullScreenDialog(Context context) {
		super(context, R.style.Dialog_Fullscreen);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_FULLSCREEN);//全屏但现实状态栏
		setContentView(R.layout.dialog_fullscreen_base);
		initView();
		getWindow().setWindowAnimations(R.style.Dialog_from_right);//动画
	}

	protected void initView(){
		mLayoutNoContent = (RelativeLayout) findViewById(R.id.layout_no_content);
		tvNoContent = (TextView) findViewById(R.id.tv_no_content);
		
		mLayoutMain = (LinearLayout)findViewById(R.id.layout_dialog_main);
		mLayoutBack = (RelativeLayout)findViewById(R.id.layout_back);
		
		mLayoutBack.setOnClickListener(this);
		btnRight = (Button)findViewById(R.id.btn_right);
		
		btnBack = (Button)findViewById(R.id.btn_back);
		ivIcon = (ImageView)findViewById(R.id.iv_icon);
		tvTitle = (TextView)findViewById(R.id.tv_title);
		
		btnBack.setOnClickListener(this);
		ivIcon.setOnClickListener(this);
		tvTitle.setOnClickListener(this);
	}
	
	protected void setMainView(View view) {
		LayoutParams params = new LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.MATCH_PARENT);
		mLayoutMain.addView(view, params);
	}

	@Override
	public void setTitle(CharSequence title) {
		tvTitle.setText(title);
		super.setTitle(title);
	}
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.layout_back:
			dismiss();
			break;
		default:
			break;
		}
	}
}
